<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'Jsp1.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    This is my JSP page. <br>
    <%
    //计算1-100之间的所有素数之和
  		int sum=0;
    	for (int i = 2;i<= 100;i++){
    	boolean k = true;
    	for (int n = 2; n < i; n++) {
    	if (i % n == 0) {
    	  k = false;
    		 break;
    	  }
    	 } 
    	
    	if(k){
    	 sum+=i;	                
    	}
    	 }
    	//out.print("1-100之间的所有素数之和是:"+sum);    
    %>
    <%= sum%>
   <hr/>
   
  
   
   <%!
 //计算闰年的方法
 int total=0;
 int count = 0;
 int runNian(int i){   
	   if((i%4==0&&i%100!=0)||i%400==0){
	         count++;
	     }
	   return count;
 }
 %>  
 	2000~2013年间闰年的个数是:
 <%
 for(int i =2000;i<=2012;i++){
	 total=runNian(i);
 }
 out.print(total);
 %>
 <hr/>
 
 
 <%!
 //显示日期
 String formatDate(Date d){
     java.text.SimpleDateFormat formater =  new java.text.SimpleDateFormat("yyyy年MM月dd日");        
     return formater.format(d);
 } 	
 %>
 现在的时间是
 	<%=formatDate(new Date())%>

 
   
   
  </body>
</html>
